package com.itwill.ecom.receiver;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("receiverService")
public class ReceiverServiceImpl implements ReceiverService {
	@Autowired
	private ReceiverDao receiverDao;
	
	public ReceiverServiceImpl(){
		
	}
	
	public void setReceiverDao(ReceiverDao receiverDao){
		this.receiverDao = receiverDao;
	}
	
	public ReceiverDao getReceiverDao(){
		return receiverDao;
	}
	
	@Override
	public boolean createReceiver(ReceiverBeans receiver) {
		boolean result = false;
		
		try{
			getReceiverDao().create(receiver);
			result = true;
		}
		catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		return result;
	}

	@Override
	public ReceiverBeans getReceiver(int o_no) {
		ReceiverBeans resultReceiver = null;
		
		try{
			resultReceiver = getReceiverDao().readReceiver(o_no);
		}
		catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		return resultReceiver;
	}

	@Override
	public boolean deleteReceiver(int o_no) {
		boolean result = false;
		
		try{
			getReceiverDao().delete(o_no);
			result = true;
		}
		catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		return result;
	}

}
